﻿<%@ Page Language="VB" MasterPageFile="~/promocionVenta.master" AutoEventWireup="false" CodeFile="descuento.aspx.vb" Inherits="mantenedores_descuento" Title=" .:: EVOLTA | Promoción ::. " %>
<%@ MasterType VirtualPath="~/promocionVenta.master" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Register Assembly="Flan.Controls" Namespace="Flan.Controls" TagPrefix="flan" %>
<%@ OutputCache Duration="15" VaryByParam="*" Location="Client" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
#txtBuscar
{
width: 299px;
}
.filaEncabezadoPrincipal
{
background-image: url('../imagenes/px_td.jpg');
width: 100%;
background-repeat: repeat;
}
.filaEncabezadoTitulo
{
background-image: url('../imagenes/submenu3.PNG');
background-repeat: repeat;
}
.filaEncabezado
{
background-image: url('../imagenes/submenu3.PNG');
width: 100%;
background-repeat: repeat;
}
.colGrilla
{
background-image: url('../imagenes/submenu2.PNG');
height: 20px;
background-repeat: repeat;
}
</style>
<script src="../javascript/Evoltat.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<table style="width: 100%; background-color: #f4f4f4;" cellspacing="0">
<tr class="filaEncabezadoPrincipal">
<td>
<table width="100%">
<tr>
<td><asp:Label ID="Label1" runat="server" CssClass="CeldaTituloTexto" Text="Mantenedor de Descuento"></asp:Label></td>
</tr>
</table>
</td>
</tr>
</table>
<asp:Panel ID="pnlDescuento" runat="server" Width="100%">
<table style="width: 100%; background-color: #f4f4f4" class="EditarLabel" cellspacing="0" border="1" cellpadding="0">
<tbody>
<tr><td style="width: 100%; padding-top: 5px; padding-bottom: 3px"></td></tr>
<tr>
<td style="width: 100%; padding-top: 5px; padding-bottom: 3px">
<asp:Label ID="Label3" runat="server" CssClass="CeldaTituloTexto" Text="Buscar: " SkinID="lblNormal"></asp:Label>
<input id="txtBuscar" runat="server" class="CsstxtFiltro" type="text" autocomplete="off" />
<input id="btnBuscar" type="button" runat="server" value="Buscar" class="CssBtnNormal" onclick="jBuscar();" />
<input id="btnAgregar" type="button" runat="server" value="Agregar" class="CssBtnNormal"/>
<asp:Button ID="btnExportar" runat="server" SkinID="btnNormalSkin" Text="Exportar" /></td>
</td>
</tr>
<tr>
<td>
<div style="width: 100%; height: 20px; scrollbar-face-color: #B5B5B5;" class="DivPanelGrillaEncabezado">
<table cellpadding="0" cellspacing="1" width="100%">
<tr align="center">
<td align="center" valign="middle" width="10%" class="colGrilla"><asp:LinkButton ID="lnkBtnCodigo" runat="server" SkinID="lnkBtnEncabezado" CommandArgument="idComoSeEntero" CommandName="idComoSeEntero" Height="100%">Código</asp:LinkButton></td>
<td align="center" valign="middle" width="14%" class="colGrilla"><asp:LinkButton ID="LinkButton3" runat="server" SkinID="lnkBtnEncabezado" CommandArgument="descComoseEntero" CommandName="descComoseEntero" Height="100%">Proyecto</asp:LinkButton></td>
<td align="center" valign="middle" width="10%" class="colGrilla"><asp:LinkButton ID="LinkButton4" runat="server" SkinID="lnkBtnEncabezado" CommandArgument="descComoseEntero" CommandName="descComoseEntero" Height="100%">Tipo Descuento</asp:LinkButton></td>
<td align="center" valign="middle" width="20%" class="colGrilla"><asp:LinkButton ID="lnkBtnDescripcion" runat="server" SkinID="lnkBtnEncabezado" CommandArgument="descComoseEntero" CommandName="descComoseEntero" Height="100%">Concepto</asp:LinkButton></td>
<!--td align="center" valign="middle" width="10%" class="colGrilla"><asp:LinkButton ID="LinkButton1" runat="server" SkinID="lnkBtnEncabezado" CommandArgument="descComoseEntero" CommandName="descComoseEntero" Height="100%">% Dscto Min.</asp:LinkButton></td-->
<td align="center" valign="middle" width="10%" class="colGrilla"><asp:LinkButton ID="LinkButton2" runat="server" SkinID="lnkBtnEncabezado" CommandArgument="descComoseEntero" CommandName="descComoseEntero" Height="100%">% Dscto Max.</asp:LinkButton></td>
<td align="center" valign="middle" width="15%" class="colGrilla"><asp:LinkButton ID="lnkBtnEstado" runat="server" SkinID="lnkBtnEncabezado" CommandArgument="descEstado" CommandName="descEstado" Height="100%">Estado</asp:LinkButton></td>
<td align="center" valign="middle" width="11%" class="colGrilla"><asp:Label ID="lblEliminar" runat="server" Text="Eliminar" SkinID="lblEncabezado"></asp:Label></td>
</tr>
</table>
</div>
<div style="overflow-y: scroll; overflow-x: hidden; width: 100%; height: 470px; scrollbar-face-color: #B5B5B5;" >
<div id="divgvwLista">
<asp:GridView ID="gvwLista" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="0" ForeColor="Black" GridLines="Vertical" Font-Names="Tahoma" DataKeyNames="idDscto" SkinID="gvwListaSkinWith100P" ShowHeader="False">
<Columns>
<asp:TemplateField HeaderText="Código">
<ItemTemplate><div onclick ="CallTheServer('divShowDet@<%# Eval("idDscto") %>');"><%#Eval("idDscto", "{0:00000}")%></div></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="10.9%" Height="20px" />
<ItemStyle HorizontalAlign="Center" Width="10.9%" Height="20px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Proyecto">
<ItemTemplate><div onclick ="CallTheServer('divShowDet@<%# Eval("idDscto") %>');"><%#Eval("descProyecto")%></div></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="14%" Height="20px" />
<ItemStyle HorizontalAlign="Left" Width="14%" Height="20px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Tipo Descuento">
<ItemTemplate><div onclick ="CallTheServer('divShowDet@<%# Eval("idDscto") %>');"><%#Eval("descTpoDescuento")%></div></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="10.5%" Height="20px" />
<ItemStyle HorizontalAlign="Left" Width="10.5%" Height="20px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Descuento">
<ItemTemplate><div onclick ="CallTheServer('divShowDet@<%# Eval("idDscto") %>');"><%#Eval("descDscto")%></div></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="20.4%" Height="20px" />
<ItemStyle HorizontalAlign="Left" Width="20.4%" Height="20px" />
</asp:TemplateField>

<asp:TemplateField HeaderText="Dscto Max">
<ItemTemplate><div onclick ="CallTheServer('divShowDet@<%# Eval("idDscto") %>');"><%#Eval("dsctoMax")%></div></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="10.7%" Height="20px" />
<ItemStyle HorizontalAlign="Center" Width="10.7%" Height="20px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Estado">
<ItemTemplate><div onclick ="CallTheServer('divShowDet@<%# Eval("idDscto") %>');"><%# Eval("descEstado") %></div></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="15%" Height="20px" />
<ItemStyle HorizontalAlign="Center" Width="15%" Height="20px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Eliminar">
<ItemTemplate><img id="imgDel" src="../Imagenes/Procesos/borrar.png" alt="Eliminar Cliente" onclick="jDeleteDetalle('<%# Eval("idDscto")%>')" style="cursor:pointer" /></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="10%" Height="20px" />
<ItemStyle HorizontalAlign="Center" Width="10%" Height="20px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</asp:Panel>
<table id="hdnInnerHtml" runat="server" ></table>
<ajax:ModalPopupExtender ID="mpDetalle" runat="server" TargetControlID="btnAgregar" BackgroundCssClass="modalBackground" DropShadow="True" PopupControlID="pnlIngresar" PopupDragHandleControlID="lblTitulo" CancelControlID="btnCancelar"></ajax:ModalPopupExtender>
<asp:Panel ID="pnlIngresar" runat="server" CssClass="modalPopup" Width="350px" Style="display: none;">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td colspan="3" bgcolor="#E44146"><asp:Label ID="lblTitulo" runat="server" SkinID="lblFormulario" Text="Descuento [Registrar]" ToolTip="Descuento"></asp:Label></td>
</tr>
<tr>
<td align="right" valign="middle">&nbsp;</td>
<td rowspan="15">&nbsp;</td>
<td>
<asp:HiddenField ID="hdfNuevo" runat="server" Value="nuevo" />
<asp:TextBox ID="txtId" runat="server" Style="display: none;"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" class="style2"><asp:Label ID="Label6" runat="server" Text="Proyecto: " SkinID="lblNormal"></asp:Label></td>
<td><div id="div1"><select id="selProyecto" runat="server" class="CssddlNormal" name="selProyecto"></select></div></td>
</tr>
<tr>
<td align="right" class="style2"><asp:Label ID="Label7" runat="server" Text="Tipo Descuento: " SkinID="lblNormal"></asp:Label></td>
<td><div id="div2"><select id="selTpoDescuento" runat="server" class="CssddlNormal" name="selTpoDescuento"></select></div></td>
</tr>
<tr>
<td align="right" valign="middle"><asp:Label ID="Label5" runat="server" Text="Descripción: " SkinID="lblNormal"></asp:Label></td>
<td><input id="txtDescDscto" runat="server" autocomplete="off" class="CsstxtNormalObligatorio" onkeypress="return ValidarAlfanumerico(event);" type="text" maxlength="35" name="txtDescDscto" />
<input id="txtDsctoMin" runat="server" autocomplete="off" class="CsstxtNormalObligatorioAlingRight" onkeypress="return validarSoloNumericoDecimales(event);" type="hidden" maxlength="5" name="txtDsctoMin" />
</td>
</tr>

<tr>
<td align="right" valign="middle"><asp:Label ID="Label4" runat="server" Text="% Dscto. Max.: " SkinID="lblNormal"></asp:Label></td>
<td><input id="txtDsctoMax" runat="server" autocomplete="off" class="CsstxtNormalObligatorioAlingRight" onkeypress="return validarSoloNumericoDecimales(event);" type="text" maxlength="5" name="txtDsctoMax" /></td>
</tr>
<tr>
<td align="right" class="style2"><asp:Label ID="Label13" runat="server" Text="Estado: " SkinID="lblNormal"></asp:Label></td>
<td><div id="divddlEstado"><select id="selEstado" runat="server" class="CssddlNormal" name="selEstado"></select></div></td>
</tr>
<tr>
<td align="right" valign="middle">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td align="right" valign="middle"><input id="btnGrabar" type="button" runat="server" value="Grabar" class="CssBtnNormal" onclick="return jSaveRecord();"/></td>
<td><input id="btnCancelar" type="button" runat="server" value="Cancelar" class="CssBtnNormal"/></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</asp:Panel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0">
<ProgressTemplate>
<div id="divProgress" class="divProgreso">
<img src="../imagenes/ajax-loader.gif" align="middle" alt="Procesando" />
<asp:Label ID="lblprogreso" runat="server" Text=" Procesando..." CssClass="EditarLabel"></asp:Label>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<flan:UpdateProgressOverlayExtender ID="UpdateProgressOverlayExtender1" runat="server" CssClass="updateProgress" OverlayType="Browser" TargetControlID="UpdateProgress1" />
<script language="javascript" type="text/javascript">
function pageLoad() {
CallTheServer('divgvwLista');
CallTheServer('divddlEstado');
}
</script>
<script language="javascript" type="text/javascript">
function ReceiveServerData(arg) {
if (!(arg == '')) {
var p = arg.toString().split('|');
var info = document.getElementById(p[0]);
switch (p[1]) {
case 'divGuardar':
case 'divModificar':
    var popup = $find('<%= mpDetalle.ClientID %>');
    popup.hide();
    if (p[2]) {
        var infoProLab = document.getElementById('divgvwLista');
        infoProLab.innerHTML = p[3];
        if ($get('<%= hdfNuevo.ClientID%>').value == 'nuevo') { alert(' Se registro correctamente.'); } else { alert(' Se modifico correctamente.'); }
    } else {
        if ($get('<%= hdfNuevo.ClientID%>').value == 'nuevo') { alert(' No se pudo registrar.'); } else { alert(' No se pudo modifico.'); }
    }
    jLimpiarControles();
    break;
case 'divShowDet':
    jLimpiarControles();
    $get('<%= lblTitulo.ClientID%>').innerHTML = p[2];
    $get('<%= hdfNuevo.ClientID%>').value = 'modificar';
    $get('<%= txtId.ClientID%>').value = p[3];
    $get('<%= txtDescDscto.ClientID%>').value = p[4];
    $get('<%= txtDsctoMin.ClientID%>').value = p[5];
    $get('<%= txtDsctoMax.ClientID%>').value = p[6];
    $get('<%= selProyecto.ClientID%>').disabled = 'disabled';
    $get('<%= selTpoDescuento.ClientID%>').disabled = 'disabled';
    $get('<%= selEstado.ClientID%>').value = p[11];
    $get('<%= selProyecto.ClientID%>').value = p[9];
    $get('<%= selTpoDescuento.ClientID%>').value = p[10];
    $get('<%= selEstado.ClientID%>').disabled = '';
    var popup = $find('<%= mpDetalle.ClientID %>');
    popup.show();
    break;
case 'divExcel':
    $get('<%= hdnInnerHtml.ClientID%>').innerText = p[2];
    exportToXL($get('<%= hdnInnerHtml.ClientID%>'));
    break;
default:
    info.innerHTML = arg.toString().replace(p[0] + '|', '');
}
}
}
</script>
<script type="text/javascript">
function exportToXL(eSrc) {
var oExcel;
var oExcelSheet;
var oWkBooks;
var cols;
oExcel = new ActiveXObject('Excel.Application');
oExcel.Visible = true;
oWkBooks = oExcel.Workbooks.Add;
oExcelSheet = oWkBooks.Worksheets(1);
oExcelSheet.Activate();
if (eSrc.tagName != 'TABLE') {
    alert('No ha sido posible exportar a excell.\n Por favor consulte con su proveedor.');
    return false;
}
cols = Math.ceil(eSrc.cells.length / eSrc.rows.length);
for (var i = 0; i < eSrc.cells.length; i++) {
    var c, r;
    r = Math.ceil((i + 1) / cols);
    c = (i + 1) - ((r - 1) * cols)
    if (eSrc.cells(i).tagName == 'th') {
        oExcel.ActiveSheet.Cells(r, c).Font.Bold = true;
        oExcel.ActiveSheet.Cells(r, c).Interior.Color = 14474460;
    }
    if (eSrc.cells(i).childNodes.length > 0 && eSrc.cells(i).childNodes(0).tagName == "B")
        oExcel.ActiveSheet.Cells(r, c).Font.Bold = true;
    oExcel.ActiveSheet.Cells(r, c).Value = eSrc.cells(i).innerText;
}
oExcelSheet.Application.Visible = true;
}
</script>
<script language="javascript" type="text/javascript">
function jMuestraPanel() {
jLimpiarControles();
return true;
}
</script>
<script language="javascript" type="text/javascript">
function jLimpiarControles() {
$get('<%= hdfNuevo.ClientID%>').value = 'nuevo';
$get('<%= txtId.ClientID%>').value = '';
$get('<%= txtDescDscto.ClientID%>').value = '';
$get('<%= txtDsctoMin.ClientID%>').value = '0.00';
$get('<%= txtDsctoMax.ClientID%>').value = '0.00';
$get('<%= selEstado.ClientID%>').selectedIndex = 1;
$get('<%= selProyecto.ClientID%>').selectedIndex = 0;
$get('<%= selTpoDescuento.ClientID%>').selectedIndex = 0;
$get('<%= selEstado.ClientID%>').disabled = 'disabled';
}
</script>
<script language="javascript" type="text/javascript">
function jValidar() {
if ($get('<%= txtDescDscto.ClientID%>').value == '') {
alert('Debe ingresar la descripción del descuento');
$get('<%= txtDescDscto.ClientID%>').focus();
return (false);
}
if ($get('<%= txtDsctoMin.ClientID%>').value.lenght == 0) {
alert('Debe ingresar un % mínimo');
$get('<%= txtDsctoMin.ClientID%>').focus();
return (false);
}
if ($get('<%= txtDsctoMax.ClientID%>').value.lenght == 0) {
alert('Debe ingresar un % máximo');
$get('<%= txtDsctoMax.ClientID%>').focus();
return (false);
}
return (true);
}
</script>
<script language="javascript" type="text/javascript">
function jSaveRecord() {
if (jValidar()) {
CallTheServer('divGuardar@' + $get('<%= hdfNuevo.ClientID%>').value + '@'
                            + $get('<%= txtId.ClientID%>').value + '@'
                            + $get('<%= txtDescDscto.ClientID%>').value + '@'
                            + $get('<%= txtDsctoMin.ClientID%>').value + '@'
                            + $get('<%= txtDsctoMax.ClientID%>').value + '@'
                            + $get('<%= selEstado.ClientID%>').value + '@'
                            + $get('<%= selProyecto.ClientID%>').value + '@'
                            + $get('<%= selTpoDescuento.ClientID%>').value + '@');
}
}
</script>
<script language="javascript" type="text/javascript">
function jBuscar() {
CallTheServer('divBuscar@' + $get('<%= txtBuscar.ClientID%>').value);
}
</script>
<script type="text/jscript" language="javascript">
function jDeleteDetalle(valor) {
res = confirm('¿Está seguro que desea eliminar el descuento?');
if (res == true) {
CallTheServer('divDelete@' + valor);
CallTheServer('divgvwLista');
}
}
</script>
<script language="javascript" type="text/javascript">
function jExcel() {
CallTheServer('divExcel@');
}
</script>
</asp:Content>